package org.luxor.commons.workflow.service;

import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.luxor.commons.workflow.entity.DeployProcess;
import org.luxor.commons.workflow.entity.ProcessDefinitionQuery;

import java.io.InputStream;
import java.util.List;

/**
 * 流程定义
 *
 * @author Mr.yan  @date 2021/10/16
 */
public interface IRepositoryCoreService {

    /**
     * 部署
     *
     * @param deployProcess 流程参数
     * @param resourceName  资源名称(如：xxx.bpmn20.xml)
     * @param inputStream   资源内容
     * @return org.activiti.engine.repository.Deployment
     */
    Deployment deploy(DeployProcess deployProcess, String resourceName, InputStream inputStream);

    /**
     * 卸载流程
     * <p>
     * 谨慎操作，会删除与之相关全部数据，包含流程定义、流程实例、该流程相关的所有历史记录。
     *
     * @param deploymentId 部署ID
     * @return
     */
    void uninstall(String deploymentId);

    /**
     * 可发起流程列表
     *
     * @param query 查询条件
     * @return org.luxor.commons.jdbc.metadata.PageResult<org.activiti.engine.repository.ProcessDefinition>
     */
    List<ProcessDefinition> listLastVer(ProcessDefinitionQuery query);

    /**
     * 历史流程列表
     *
     * @param processDefinitionKey 流程定义KEY
     * @return org.luxor.commons.jdbc.metadata.PageResult<org.activiti.engine.repository.ProcessDefinition>
     */
    List<ProcessDefinition> listHistoryVer(String processDefinitionKey);

    /**
     * 获取预览图
     *
     * @param processDefinitionId 流程定义ID
     * @return java.io.InputStream
     */
    InputStream getImage(String processDefinitionId);

    /**
     * 导出
     *
     * @param processDefinitionId 流程定义ID
     * @return java.io.InputStream
     */
    InputStream export(String processDefinitionId);

    /**
     * 查看
     *
     * @param deploymentId 部署ID
     * @return org.activiti.engine.repository.ProcessDefinition
     */
    ProcessDefinition getByDeploymentId(String deploymentId);

    /**
     * 查看
     *
     * @param processDefinitionId 流程定义ID
     * @return org.activiti.engine.repository.ProcessDefinition
     */
    ProcessDefinition get(String processDefinitionId);

    /**
     * 激活
     *
     * @param processDefinitionId 流程定义ID
     */
    void activate(String processDefinitionId);

    /**
     * 挂起
     *
     * @param processDefinitionId 流程定义ID
     */
    void suspend(String processDefinitionId);

}
